<?php
using("Utils_Xml_Parser");

class Tests_Utils_Xml_Parser extends UnitTestCase {
	
	
	public function testConstruct() {
		try {
			$parser = new Utils_Xml_Parser();
			$this->pass();
		} catch (Utils_Exceptions_Xml $e) {
			$this->fail();
		}
	}
	
	public function testParseString() {
		try {
			$xml = file_get_contents(Tests_Files_Catalog::fetch("test.xml"));
			$parser = new Utils_Xml_Parser();
			$parser->parse($xml);
			$this->pass();
		} catch (Utils_Exceptions_Xml $e) {
			$this->fail();
		}
		
		try {
			$xml = "hello world";
			$parser = new Utils_Xml_Parser();
			$parser->parse($xml);
			$this->fail();
		} catch (Utils_Exceptions_Xml $e) {
			$this->pass();
		}
		
	}
	
	public function testParseFile() {
		try {
			$parser = new Utils_Xml_Parser();
			$parser->parseFile(Tests_Files_Catalog::fetch("test.xml"));
			$this->pass();
		} catch (Utils_Exceptions_Xml $e) {
			$this->fail();
		}
		
		try {
			$parser = new Utils_Xml_Parser();
			$parser->parseFile(Tests_Files_Catalog::fetch("foo.xml"));
			$this->fail();
		} catch (Utils_Exceptions_Xml $e) {
			$this->pass();
		}
	}
}
?>